(function(){
	
	function DebugPanel(){
		var infoPanelHtml = '<div id="debug-info"><ul id=""><ul/><div></div></div>';
		var document = window.document;
		var body = document.body;
		var infoPanel = document.createElement("div");
		var infoList = document.createElement("ul");
		var ocBtn = document.createElement("div");
		var elementCssText = {
			infoPanel:"font-size: 12px;height:0px;overflow:hidden; background:#deebf1;",
			infoList:"",
			infoItem:"border-bottom: 1px solid;",
			infoItemTitle:"",
			infoItemInfo:"",
			ocBtn:"position:fixed;bottom:0px;left:0px;z-index:3000;border-image:initial;height:40px;width:100px;border:1px solid rgb(221, 221, 221);"
		};
		//初始化信息面板
		function _initPanel(){
			//初始化样式
			infoPanel.style.cssText = elementCssText.infoPanel;
			infoList.style.cssText = elementCssText.infoList;
			ocBtn.style.cssText = elementCssText.ocBtn;
			ocBtn.innerHTML="打开";
			
			//组合元素
			infoPanel.appendChild(infoList);
			infoPanel.appendChild(ocBtn);
			body.insertBefore(infoPanel,body.firstChild);
		};
		
		//清除信息
		function _clearInfo(e){
			infoList.innerHTML="";
		}
		function _ocClick(){
			var height = infoPanel.style.height;
			if(height==="auto"){
				infoPanel.style.height ="0px"; 
				ocBtn.innerHTML="打开";
			}else{
				infoPanel.style.height ="auto"; 
				ocBtn.innerHTML="关闭";
			}
		}
		function _initEvent(){
			infoList.addEventListener("click",_clearInfo);
			ocBtn.addEventListener("click",_ocClick); 
		}
		
		//添加调试信息
		function _addInfo(msg){
			var li = document.createElement("li");
			//添加样式
			li.style.cssText = elementCssText.infoItem;
			
			li.innerHTML = msg;
			
			infoList.appendChild(li);
		}
		function _addInfo2(msg){
			var li = document.createElement("li");
			//var title = document.createElement("div");
			//var info = document.createElement("div");
			//添加样式
			li.style.cssText = elementCssText.infoItem;
			//title.style.cssText = elementCssText.infoItemTitle;
			//info.style.cssText = elementCssText.infoItemInfo;
			//title.innerHTML = "调试信息item点击打开";
			//info.innerHTML = msg;
			li.innerHTML = msg;
			//li.appendChild(title);
			//li.appendChild(info);
			infoList.appendChild(li);
		}
		this.log = function(msg){
			_addInfo(msg);
		}
		function _init(){
			_initPanel();
			_initEvent();
		}
		_init();
	}
	var debugPanel = new DebugPanel();
	window.debugToPanel = debugPanel.log;
	window.log = debugPanel.log;
})();